<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" @submit.native.prevent v-show="showSearch" label-width="68px">
      <el-form-item label="物料编号" prop="productNo">
        <el-input
          v-model="queryParams.productNo"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库" prop="storehouseNo">
        <el-select v-model="queryParams.storehouseNo" clearable placeholder="请选择仓库"  >
          <el-option
            v-for="dict in storehouseList"
            :key="dict.no"
            :label="dict.name"
            :value="dict.no"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="businessList" >
      <el-table-column label="物料编号" align="center" prop="productNo" />
      <el-table-column label="物料名称" align="center" prop="productName" />
      <el-table-column label="库存总数" align="center" prop="yjcTotalQty" />
      <el-table-column label="库存可用总数" align="center" prop="yjcUseTotalQty" />
      <el-table-column label="库存占用总数" align="center" prop="yjcOccupyTotalQty" />
      <el-table-column label="库存锁定总数" align="center" prop="yjcLockTotalQty" />
      <el-table-column label="库存冻结总数" align="center" prop="yjcFreeTotalQty" />
      <el-table-column label="库存不良品总数" align="center" prop="yjcNGTotalQty" />
      <el-table-column label="库存退货品总数" align="center" prop="yjcReturnTotalQty" />
      <el-table-column label="待检仓总数" align="center" prop="djcTotalQty" />
      <el-table-column label="退货&报废总数" align="center" prop="scrapToalQty" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
import { listBusiness } from "@/api/storehouse/stock/inventoryOverview";
import { listStorehouse } from "@/api/basic/storehouse";

export default {
  dicts: [],
  name: "Business",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 库存表格数据
      businessList: [],
      storehouseList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        no: null,
        storehouseNo: null,
        storehouseAreaNo: null,
        storehouseLocationNo: null,
        barcode: null,
        productNo: null,
        productVersion: null,
        productName: null,
        batchNo: null,
        qty: null,
        company: null,
        status: null,
        isCheckLock: null,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
    this.getStorehouse();
  },
  methods: {
    /** 查询库存列表 */
    getList() {
      this.loading = true;
      listBusiness(this.queryParams).then(response => {
        this.businessList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询仓库列表 */
    getStorehouse() {
      listStorehouse({
        pageSize:0
      }).then(response => {
        this.storehouseList = response.rows;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        no: null,
        storehouseNo: null,
        storehouseAreaNo: null,
        storehouseLocationNo: null,
        barcode: null,
        productNo: null,
        productVersion: null,
        productName: null,
        batchNo: null,
        qty: null,
        company: null,
        status: "0",
        isCheckLock: null,
        remark: null,
        delFlag: null,
        createBy: null,
        updateBy: null,
        updateTime: null,
        createTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

  }
};
</script>
